package com.strawcom.charmring.bean.http;

import java.util.ArrayList;
import java.util.List;

import com.strawcom.charmring.bean.Calories;
import com.strawcom.charmring.bean.DailySummary;

public class ExerciseRequest extends BaseRequest {

	private static final long serialVersionUID = -4586860156441104866L;

	public List<DailySummaryRequest> everyday_summary_tbl;

	public static class DailySummaryRequest {

		/** 日期 yyyyMMdd */
		public String date;

		public double weight;
		/** 目标能量 */
		public int tgtcalorie;
		/** 目标时间 */
		public int tgttime;

		/** 消耗卡路里列表 每种运动方式一个 */
		public List<CaloriesRequest> calories;

		public static DailySummaryRequest convertByDailySummary(DailySummary dailySummary) {
			DailySummaryRequest dsr = new DailySummaryRequest();
			dsr.date = dailySummary.getDate();
			dsr.weight = dailySummary.getWeight();
			dsr.tgtcalorie = (int) dailySummary.getTargetEnergy();
			dsr.tgttime = dailySummary.getTargetTime();
			final List<CaloriesRequest> calories = new ArrayList<CaloriesRequest>();
			for (Calories c : dailySummary.getOriginalCalories()) {
				CaloriesRequest cr = CaloriesRequest.convertByCalories(c);
				calories.add(cr);
			}
			dsr.calories = calories;
			return dsr;
		}

	}

	public static class CaloriesRequest {

		/** 持续时间 分钟　 */
		public int lasttm;
		/** 运动类型 */
		public int type;
		/** km */
		public double distance;

		public double calorie;

		public static CaloriesRequest convertByCalories(Calories calories) {
			CaloriesRequest cr = new CaloriesRequest();
			cr.lasttm = calories.getDuration();
			cr.type = calories.getType();
			cr.distance = calories.getDistance() / 1000;
			cr.calorie = calories.getCalorie();
			return cr;
		}
	}
}
